import { ArrayMaxSize, ArrayMinSize, IsArray, IsNotEmpty, IsNumber, IsOptional, IsString, Max, MaxLength, Min } from "class-validator";

class CommonDto {
    @MaxLength(10, {message : '权限名长度不能超过10个字符'})
    @IsNotEmpty({message : '请填写权限名'})
    @IsString({message : '数据非法'})
    name:string;

    @MaxLength(30, {message : '编码长度不能超过10个字符'})
    @IsNotEmpty({message : '请填写编码'})
    @IsString({message : '数据非法'})
    code:string;

    @ArrayMaxSize(5, {message : '请求类型最多5个'})
    @IsArray({message : '数据非法'})
    urls : string[]

    @ArrayMaxSize(5, {message : '请求类型最多5个'})
    @IsArray({message : '数据非法'})
    @IsOptional()
    methods : ('POST' | 'GET' | 'PUT' | 'DELETE')[]

    @MaxLength(30, {message : '备注长度不能超过30个字符'})
    @IsString({message : '数据非法'})
    @IsOptional()
    remark:string;
}

export class AddRuleDto extends CommonDto {
    @Min(0, {message : '数据非法'})
    @IsNumber({}, {message : '数据非法'})
    menuId:number;
}

export class EditRuleDto extends CommonDto {
    
}

export class DeleteRuleDto {
    @ArrayMinSize(1, {message : '数据非法'})
    @IsArray({message : '数据非法'})
    ids : number[]
}